package ru.spb.osll.myfit.common.chart;

import com.thoughtworks.xstream.annotations.XStreamAlias;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * User: Artem Bukhonov
 * Email: nerzhulart@gmail.com
 * Date: 10.11.11
 * Time: 16:40
 */
@XStreamAlias("curve")
public class ChartCurve implements Serializable {
  private static final long serialVersionUID = -3606638177362998901L;

  @XStreamAlias("points")
  private List<ChartPoint> m_points = new ArrayList<ChartPoint>();
  @XStreamAlias("name")
  private String m_name = "";

  @XStreamAlias("color")
  private int m_colorRGB;

  public ChartCurve() {}

  public ChartCurve(String name) {
    m_name = name;
  }


  public String getName() {
    return m_name;
  }

  public void setName(String name) {
    m_name = name;
  }

  public List<ChartPoint> getPoints() {
    return m_points;
  }
  public int getColor() {
    return m_colorRGB;
  }

  public void setColor(int color) {
    m_colorRGB = color;
  }

  public int getColorRGB() {
    return m_colorRGB;
  }

  public void setColorRGB(int colorRGB) {
    m_colorRGB = colorRGB;
  }

  public String getHexColorCode() {
    String colorString = Integer.toHexString(m_colorRGB);
    StringBuilder stringBuilder = new StringBuilder("#");
    stringBuilder.append(new String(new char[6 - colorString.length()]).replace("\0", "0"));
    stringBuilder.append(colorString);
    return stringBuilder.toString();
  }
}
